package offer;

import java.util.ArrayList;
import java.util.List;

public class offerII_0018 {
    public boolean isPalindrome(String s) {
        s=s.toLowerCase();
        int len=s.length();
        ArrayList<Character> list=new ArrayList<>(len/2);
        for(int i=0;i<len;++i){
            char a=s.charAt(i);
            if(a>='0'&&a<='9'||a>='a'&&a<='z'){
                list.add(a);
            }
        }
        int left=0;
        int right=list.size()-1;
        while(left<right){
            if(list.get(left)!=list.get(right)) return false;
            left++;
            right--;
        }
        return true;
    }
}
